package com.it.blog.tools;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @Author: 羡羡
 * @Date: 2022/01/30/21:19
 *
 * 加密工具
 */
public class Md5Tools {
    public static final String KEY_MD5 = "MD5";

    /**
     * MD5生成工具
     * @param context 传入的值
     * @return 返回MD5的结果
     * @throws NoSuchAlgorithmException
     */
    public static String getmdresult(String context) throws NoSuchAlgorithmException {
        BigInteger bigInteger=null;
        MessageDigest md = MessageDigest.getInstance(KEY_MD5);
        byte[] inputData = context.getBytes();
        md.update(inputData);
        bigInteger = new BigInteger(md.digest());
        return bigInteger.toString(16);
    }
}
